<template>
  <div>
    <h1>熊二</h1>
    <h1>熊大给{{ info }}</h1>
    <xiao-xiong-er></xiao-xiong-er>
    <button @click="giveButterfly">给小熊大一只蝴蝶</button>
  </div>
</template>

<script>
/* 
熊二有一只小蝴蝶  给小熊大
小熊大是熊大的子组件

谁是接收消息      小熊大接收消息
谁是提供消息 发布消息  熊二发布消息

*/
import PubSub from "pubsub-js";
import XiaoXiongEr from "./XiaoXiongEr";
export default {
  data() {
    return {
      info: "",
      anim: "有一只小蝴蝶",
    };
  },
  mounted() {
    this.$eventBus.$on("geGive", (msg) => {
      console.log(msg);
      this.info = msg;
    });
  },
  components: {
    XiaoXiongEr,
  },
  methods: {
    giveButterfly() {
      // 发布消息
      PubSub.publish("yangyang", this.anim);
    },
  },
};
</script>

<style lang="scss" scoped>
</style>